package org.javaboy.demo;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration
public class JavaConfig {

    @Bean
    //这个表示WindowsCondition#matches方法返回 true，这个 bean 才会注册到 Spring 容器
    @Conditional(WindowsCondition.class)
    ShowCmd winCmd() {
        System.out.println("winCmd");
        return new WindowsShowCmd();
    }

    @Bean
    //这个表示LinuxCondition#matches方法返回 true，这个 bean 才会注册到 Spring 容器
    @Conditional(LinuxCondition.class)
    ShowCmd linuxCmd() {
        System.out.println("linuxCmd");
        return new LinuxShowCmd();
    }
}
